package cn.fansunion.leecode.todo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 给定一个仅包含数字 2-9 的字符串，返回所有它能表示的字母组合。答案可以按 任意顺序 返回。
 * 
 * 给出数字到字母的映射如下（与电话按键相同）。注意 1 不对应任何字母。
 * 
 * 来源：力扣（LeetCode） 链接：https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number
 * 著作权归领扣网络所有。商业转载请联系官方授权，非商业转载请注明出处。
 * 
 * @author wen.lei@brgroup.com
 *
 *         2021-12-28
 */
public class LetterCombinationsOfAPhoneNumber {

    /**
     * @param args
     */
    public static void main(String[] args) {
        System.out.println(letterCombinations("23"));

    }

    static Map<Integer, List<String>> numLetterMap = new HashMap<>();
    static{
        numLetterMap.put(1, Arrays.asList());
        numLetterMap.put(2, Arrays.asList("a", "b", "c"));
        numLetterMap.put(3, Arrays.asList("d", "e", "f"));
        numLetterMap.put(4, Arrays.asList("g", "h", "i"));
        numLetterMap.put(5, Arrays.asList("j", "k", "l"));
        numLetterMap.put(6, Arrays.asList("m", "n", "o"));
        numLetterMap.put(7, Arrays.asList("p", "q", "r", "s"));
        numLetterMap.put(8, Arrays.asList("t", "u", "v"));
        numLetterMap.put(9, Arrays.asList("w", "x", "y", "z"));
    }

    // 输入：digits = "23"
    // 输出：["ad","ae","af","bd","be","bf","cd","ce","cf"]
    public static List<List<String>> letterCombinations(String digits) {
        if (digits == null || digits.equals("")) {
            return new ArrayList<>();
        }
        List<List<String>> letterList = new ArrayList<>();
        for (int i=0;i<  digits.length();i++) {
            char num=digits.charAt(i);
            Integer valueOf = Character.getNumericValue(num);
            List<String> oneLetterList = numLetterMap.get(valueOf);
            if (num != 1) {
                letterList.add(oneLetterList);
            }
        }
        return combinList(letterList);
    }

    private static List<List<String>> combinList(List<List<String>> letterList) {
        // TODO Auto-generated method stub
        return null;
    }
}
